!===============================================================
!
! Funzione di HARTMAN (n=6)
!
!===============================================================
!			VARIABLE BOUNDS
!===============================================================
!	0.D0                1.D0                Limits of variable 1
!	0.D0                1.D0                  "        "       2
!	0.D0                1.D0                  "        "       3
!	0.D0                1.D0                  "        "       4
!	0.D0                1.D0                  "        "       5
!	0.D0                1.D0                  "        "       6

SUBROUTINE HARTMAN6(X,N,F)

      IMPLICIT NONE

      INTEGER          :: N
      DOUBLE PRECISION :: X(N), F

      DOUBLE PRECISION :: A(4,6), C(4), P(4,6), FA
      INTEGER          :: I, J

        A(1,1)=10.D0
        A(2,1)=0.05D0
        A(3,1)=3.D0
        A(4,1)=17.D0

        A(1,2)=3.D0
        A(2,2)=10.D0
        A(3,2)=3.5D0
        A(4,2)=8.D0

        A(1,3)=17.D0
        A(2,3)=17.D0
        A(3,3)=1.7D0
        A(4,3)=0.05D0

        A(1,4)=3.5D0
        A(2,4)=0.1d0
        A(3,4)=10.D0
        A(4,4)=10.D0

        A(1,5)=1.7D0
        A(2,5)=8.D0
        A(3,5)=17.D0
        A(4,5)=0.1D0

        A(1,6)=8.D0
        A(2,6)=14.D0
        A(3,6)=8.D0
        A(4,6)=14.D0

        C(1)=1.D0
        C(2)=1.2D0
        C(3)=3.D0
        C(4)=3.2D0

        P(1,1)=0.1312D0
        P(2,1)=0.2329D0
        P(3,1)=0.2348D0
        P(4,1)=0.4047D0

        P(1,2)=0.1696D0
        P(2,2)=0.4135D0
        P(3,2)=0.1451D0
        P(4,2)=0.8828D0

        P(1,3)=0.5569D0
        P(2,3)=0.8307D0
        P(3,3)=0.3522D0
        P(4,3)=0.8732D0

        P(1,4)=0.0124D0
        P(2,4)=0.3736D0
        P(3,4)=0.2883D0
        P(4,4)=0.5743D0

        P(1,5)=0.8283D0
        P(2,5)=0.1004D0
        P(3,5)=0.3047D0
        P(4,5)=0.1091D0

        P(1,6)=0.5886D0
        P(2,6)=0.9991D0
        P(3,6)=0.6650D0
        P(4,6)=0.0381D0

        F  = 0.0D0
        FA = 0.0D0

        DO I=1,4
           DO J=1,6
              FA = FA +A(I,J)*((X(J)-P(I,J))**2)
           END DO
           F  = F -C(I)*DEXP(-FA)
           FA = 0.0D0
        END DO

      RETURN

END
